<!-- 借支申请-工人页面发起端 -->
<template>
	<view>
		<bg-tab :current="current" :tabs="tabs" @tab-change="tabChange"></bg-tab>
		<view class="m-3">
			<scroll-view :scroll-y="true" class="scroll-block" v-if='dataList.length >0'>
				<view class="bt-block py24px30 mb-3" @tap="gotoDetail(i)" v-for="i in dataList" :key="i.id">
					<view class="flex">
						<view class="flex-1">
							<bg-desc label="申请人" :value="i.createUserName"></bg-desc>
							<bg-desc label="借支金额" :value="i.amount+'元'"></bg-desc>
							<bg-desc label="项目名称" :valueStyle="{width:'170px', }" :value="i.projectName"></bg-desc>
							<bg-desc label="提交时间" :valueStyle="{width:'170px'}" :value="i.createTime"></bg-desc>
						</view>
						<view class="flex align-center">
							<u--image v-if="i.status==1" width="148rpx" height="148rpx" src="/static/images/ui/salary/wait.png"></u--image>
							<u--image v-if="i.status==2" width="148rpx" height="148rpx" src="/static/images/ui/salary/pass.png"></u--image>
							<u--image v-if="i.status==3" width="148rpx" height="148rpx" src="/static/images/ui/salary/unpass.png"></u--image>
						</view>
					</view>
				</view>
			</scroll-view>
			<u-empty v-else></u-empty>
		</view>
		
	</view>
</template>

<script>
	import {borrowList} from "@/api/salary.js"
	export default {
		onNavigationBarButtonTap() {
			uni.navigateTo({
				url:"/pages/salary/borrow/borrow"
			})
		},
		data() {
			return {
				current:0,
				tabs:[
					"待审批","审批通过","审批未通过"
				],
				params:{
					status:1,
				},
				dataList:[]
			}
		},
		mounted() {
			this.getList()
			uni.$on("refresh-borrow", ()=>{
				this.getList()
			})
		},
		methods: {
			getList(){
				this.dataList = []
				borrowList(this.params).then(res=>{
					this.dataList = res.data.rows
				})
			},
			tabChange(idx){
				this.current = idx
				this.params.status = idx+1
				this.getList()
			},
			gotoDetail(i){
				uni.navigateTo({
					url:"/pages/salary/borrow/detail?show=1&id="+i.id
				})
			}
		}
	}
</script>

<style>

</style>
